﻿using System;

namespace Core.Helper
{
    public class StringUtil
    {        
        /// <summary>
        /// 字段为空判断
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool isBlank(string str)
        {
            return string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str);
        }

        /// <summary>
        /// 截取字符串
        /// </summary>
        /// <param name="input"></param>
        /// <param name="size"></param>
        /// <param name="showDot"></param>
        /// <returns></returns>
        public static string subString(string input, int size, bool showDot = false)
        {
            if (input.Length < size)
            {
                return input;
            }
            else
            {
                input = input.Substring(0, size);
                if (showDot)
                {
                    input = input + "...";
                }
                return input;
            }
        }
    }
}
